package msc.ai.crypto.jade.security.keymanager;

import java.util.Date;

import javax.crypto.SealedObject;
import javax.crypto.SecretKey;
import jade.core.AID;
import jade.util.leap.Serializable;

public class AgentSharedKeyDetails implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 2839175117105469589L;
	
	private AID fromAgent;
	private AID toAgent;
	private Date initiateTime;
	private Date lastAccessTime;
	private long nonceFrmAgt; //TODO : Use nonce validation
	private long nonceToAgt;  //TODO : Use nonce validation 
	private SecretKey sharedKey;
	
//	private byte[] sharedKey_toAgt_Wraped; // secure with toAgent's private key with KDC
	/**
	 * This is another AgentSharedKeyDetails Sealed with toAgent's public key with KDC
	 */
	private SealedObject sharedKey_toAgt_Sealed; 
	
	
	public AgentSharedKeyDetails(AID frmAgent, AID toAgt)
	{
		this.fromAgent = frmAgent;
		this.toAgent = toAgt;
		this.initiateTime = new Date(System.currentTimeMillis());
	}
	
	
	public AID getFromAgent()
	{
		return this.fromAgent;
	}
	public void setFromAgent(AID fromAgent)
	{
		this.fromAgent = fromAgent;
	}
	
	public AID getToAgent()
	{
		return this.toAgent;
	}
	public void setToAgent(AID toAgent)
	{
		this.toAgent = toAgent;
	}
	
	public SecretKey getSharedKey()
	{
		this.lastAccessTime = new Date(System.currentTimeMillis());
		return this.sharedKey;
	}
	public void setSharedKey(SecretKey sharedKey)
	{
		this.sharedKey = sharedKey;
	}

	public SealedObject getSharedKey_toAgt_Sealed()
	{
		this.lastAccessTime = new Date(System.currentTimeMillis());
		return this.sharedKey_toAgt_Sealed;
	}	
	public void setSharedKey_toAgt_Sealed(SealedObject sharedKeyToAgtSealed)
	{
		this.sharedKey_toAgt_Sealed = sharedKeyToAgtSealed;
	}
	
	public Date getInitiateTime()
	{
		return this.initiateTime;
	}
	
	public Date getLastAccessTime()
	{
		return this.lastAccessTime;
	}


	public long getNonceFrmAgt()
	{
		return nonceFrmAgt;
	}


	public void setNonceFrmAgt(long nonceFrmAgt)
	{
		this.nonceFrmAgt = nonceFrmAgt;
	}


	public long getNonceToAgt()
	{
		return nonceToAgt;
	}


	public void setNonceToAgt(long nonceToAgt)
	{
		this.nonceToAgt = nonceToAgt;
	}
	
	
	
	
	
	
	
}
